package com.struts.web.manage.admin.corpor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;

import com.base.Constants;
import com.lg.system.CLGAction;
import com.struts.deal.admin.corpor.Deal;

public class EditRecommendAction extends CLGAction {

	public ActionForward execute(ActionMapping actionMapping, ActionForm form,
			HttpServletRequest request,
			HttpServletResponse response) throws
			Exception {
		QueryBlackForm aWebForm = (QueryBlackForm)form;
		ActionMessages msgs = new ActionMessages();
		boolean result = false;
		if(aWebForm.getMethod()!=null && aWebForm.getMethod().equals("edit")){
			result = Deal.editRecommend(request, aWebForm);
			System.out.println("222222222;"+result);
			if(result==true){
				System.out.println("3333333333;");
				return actionMapping.findForward("successmessages");
			}else{
				msgs.add("commonMsgs",new ActionMessage(Constants.EDIT_FAIL));
				saveErrors(request,msgs);
				return actionMapping.findForward("fail");
			}
		}else{
			result = Deal.doEditRecommendDefault(request, aWebForm);
			if(result==false){
				msgs.add("commonMsgs",new ActionMessage(Constants.NOTEXIST_OR_DEL));
				saveErrors(request,msgs);
				return actionMapping.findForward("fail");
			}

			return actionMapping.getInputForward();
		}
	}
}
